package com.linxz.ui.spraycarview;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;


public class CarDirection extends ArrayList<ICarPart> {

  public void init(int viewWidth, int viewHeight){
       List<ICarPart> list=new ArrayList<>(this);
       for(ICarPart part:list){
          part.adjustPosition(viewWidth,viewHeight);
       }
       //将面积最小的部件放置顶部，点击优先判断
      Collections.sort(this, new Comparator<ICarPart>() {
          @Override
          public int compare(ICarPart o1, ICarPart o2) {
              int area1=o1.getWidth()*o1.getHeight();
              int area2=o2.getWidth()*o2.getHeight();
              return area1>=area2?-1:1;
          }
      });
  }

}
